<template>
	<div class="index">
      <el-dialog :title="title" center :visible.sync="log" width="1000px" :close-on-click-modal="false" @close="gianbi">
        <el-table :data="list" border :header-cell-style="{'border-bottom':'solid 1px #d2d3da','text-align':'center','background-color':'#eaeaea'}" style="width: 100%" >

          <el-table-column  prop="date" align="center" label="日期"></el-table-column>
          <el-table-column  label="推广费用">
            <template slot-scope="scope">
              <el-input v-model="scope.row.promote_cost" placeholder="请输入推广费用"></el-input>
            </template>
          </el-table-column>
          <el-table-column  label="其他费用">
            <template slot-scope="scope">
              <el-input v-model="scope.row.other_cost" placeholder="请输入其他费用"></el-input>
            </template>
          </el-table-column>
          <el-table-column  label="达人订单">
            <template slot-scope="scope">
              <el-input v-model="scope.row.star_order" placeholder="请输入达人订单"></el-input>
            </template>
          </el-table-column>
          <el-table-column  label="短视频订单">
            <template slot-scope="scope">
              <el-input v-model="scope.row.video_order" placeholder="请输入短视频订单"></el-input>
            </template>
          </el-table-column>
          <el-table-column  label="推广订单">
            <template slot-scope="scope">
              <el-input v-model="scope.row.promote_order" placeholder="请输入推广订单"></el-input>
            </template>
          </el-table-column>
          <el-table-column  label="观看成交率">
            <template slot-scope="scope">
              <el-input v-model="scope.row.deal_rate" placeholder="请输入观看成交率">
                <template slot="append">%</template>
              </el-input>
            </template>
          </el-table-column>

          <!-- <el-table-column  label="操作" align="center" >
            <template slot-scope="scope">
              <el-button type="danger" round :disabled="ing" @click="queding(scope.row)">保存</el-button>
            </template>
          </el-table-column> -->

        </el-table>
        <div slot="footer" class="dialog-footer">
          <el-button type="danger" round @click="queding()">保存</el-button>
        </div>
      </el-dialog>
	</div>
</template>

<script>
  import axios from 'axios'
  import moment from 'moment'
	export default{
		name: 'index',
    props:['source','date2','title'],
		data(){
			return{
        log:true,
        all:{
          source:this.source,
          date:this.date2
        },
        list:[],
        times:[]
			}
		},
		created() {
      this.getlist()
		},
    mounted() {

    },
		methods:{
      gianbi:function(){
        this.$emit('yunxinggengxin')
      },
      queding:function(item){
        axios.post('/api/form/source/cost2',this.list[0])
          .then(response => {
            if (response.data.msg.code == 0) {
              this.$message.success('更新成功');
              this.getlist()

              this.log = false
              this.$emit('yunxinggengxin')
            } else {
              this.$message.error(response.data.msg.info);
            }
          })
      },
      getlist:function(){
        axios.get('/api/form/source/cost/info2',{params:this.all})
          .then(response => {
            if (response.data.msg.code == 0) {
              if(response.data.data == null){
                this.list = [
                  {
                    "id": "",
                    "shop_id": "",
                    "source": this.source,
                    "date": this.date2,
                    "promote_cost": "",
                    "other_cost": "",
                    "promote_order": "",
                    "video_order": "",
                    "deal_rate": "",
                    "created_at": "",
                    "updated_at": ""
                  }
                ]
              }else{
                this.list = [response.data.data]
              }
            } else {
              this.$message.error(response.data.msg.info);
            }
          })
      }
		}
	}
</script>

<style lang="scss" scoped>
	.index{

	}
</style>
